import re

# 字符串分割
from string import Template

jwstr = 'zhangsan,lisi,wangwu'
jwlist = jwstr.split(',')
print(jwlist)  #列表

# 字符串提取
jw1 = 'lsafbsafhbs,${aaaaaaaaaaaa},lsfsaoi${bbbbbb}'
zhengze = "\\${(.*?)}"
print(re.findall(zhengze, jw1))

# 字符串替换
jwstr2 = 'sjfahs,${jwtoken}'
shangyou_jieguo = {'jwtoken':'aaaaaa'}
geng_huan = Template(jwstr2)
new_str = geng_huan.safe_substitute(shangyou_jieguo)
print(new_str)

# 字符串转换
data = "{'username':'zhangsan','password':'123456'}"
print(type(data))
data2 = eval(data)
print(data2,data)
print(type(data2))
print(data2['password'])